﻿package com.hirisun.wicket;

 
 
import java.io.Serializable;

import org.apache.wicket.Component;
import org.apache.wicket.extensions.markup.html.repeater.data.table.filter.TextFilter;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.basic.MultiLineLabel;
import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.request.cycle.RequestCycle;
import org.apache.wicket.util.string.StringValue;

import com.hirisun.domain.Person;

public class HelloWorld extends WebPage {
	private Person p =new Person() ;
	

 


	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	public HelloWorld(){
		super();
		 
		 
		 add(new FeedbackPanel("feedback"));
		 
		 Label lable = new Label("label", "<span>显示label！</span>");
 		 lable.setEscapeModelStrings(true);
		 
		/// 添加 label
		 add(lable );
		 add(new MultiLineLabel("multiLineLable", "username<br>  password!").setEscapeModelStrings(false));
		 @SuppressWarnings("rawtypes")
		Form  form = new Form ("form1"){
			 @Override
			protected void onSubmit() {
				 
				    	
				    		info("Saved model "+p);
				    		debug("Saved model "+p);
				    		success("Saved model "+p);
				    		warn("Saved model "+p);
				   
			}
		 };
		 StringValue parameterValue =  RequestCycle.get().getRequest().getQueryParameters().getParameterValue("name");
		 System.out.println(parameterValue);
	   
	      form.add( new Label("lable", "请输入姓名："));
	    form.add(new TextField<String>("name",new PropertyModel<String>(this,parameterValue.toString()) ));
	    form.add( new Label("lable1", "请输入年龄："));
	    form.add(new TextField<Integer>("age",new PropertyModel<Integer>(p, "age") ));
	    form.add(new Button("submit"));
 
	  
	    
	    add(form);
	}

	@Override
	public String toString() {
		//GET request
		
		
		return "HelloWorld [p=" + p + "]";
	}
	

 
	

}
